﻿
USE DBDAYNGHE

------------------------------------------------------------------------------------------
/*
	sp_ADD_TYPE_CATEGORY : THÊM 1 LOẠI TIN TỨC
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_ADD_TYPE_CATEGORY') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_ADD_TYPE_CATEGORY

GO

CREATE PROCEDURE sp_ADD_TYPE_CATEGORY
(	
	@NAME NVARCHAR(200),
	@DESCRIPTION NVARCHAR(300),
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

INSERT INTO TYPECATEGORY 
VALUES(@NAME, @DESCRIPTION, @SORTED, @RECORD_STATUS)


------------------------------------------------------------------------------------------
/*
	sp_UPDATE_TYPE_CATEGORY : CẬP NHẬT 1 LOẠI TIN TỨC
*/
GO
if exists (select * from sysobjects where id = object_id('dbo.sp_UPDATE_TYPE_CATEGORY') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_UPDATE_TYPE_CATEGORY

GO

CREATE PROCEDURE sp_UPDATE_TYPE_CATEGORY
(
	@ID INT,
	@NAME NVARCHAR(200),
	@DESCRIPTION NVARCHAR(300),
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

UPDATE TYPECATEGORY
SET  NAME = @NAME
	,DESCRIPTION = @DESCRIPTION
	,SORTED = @SORTED
	,RECORD_STATUS = @RECORD_STATUS
WHERE ID = @ID


------------------------------------------------------------------------------------------
/*
	sp_ADD_CATEGORY : THÊM 1 NHÓM TIN TỨC
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_ADD_CATEGORY') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_ADD_CATEGORY

GO

CREATE PROCEDURE sp_ADD_CATEGORY
(	
	@NAME NVARCHAR(200),
	@TYPECATEID INT,		
	@DESCRIPTION NVARCHAR(500),
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

INSERT INTO CATEGORY 
VALUES(@NAME, @TYPECATEID, @DESCRIPTION, @SORTED, @RECORD_STATUS)


------------------------------------------------------------------------------------------
/*
	sp_UPDATE_CATEGORY : CẬP NHẬT 1 NHÓM TIN TỨC
*/
GO
if exists (select * from sysobjects where id = object_id('dbo.sp_UPDATE_CATEGORY')
and sysstat & 0xf = 4)  drop procedure dbo.sp_UPDATE_CATEGORY

GO

CREATE PROCEDURE sp_UPDATE_CATEGORY
(
	@ID INT,
	@NAME NVARCHAR(200),
	@TYPECATEID INT,
	@DESCRIPTION NVARCHAR(300),
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

UPDATE CATEGORY
SET  NAME = @NAME
	,TYPECATEID = @TYPECATEID
	,DESCRIPTION = @DESCRIPTION
	,SORTED = @SORTED
	,RECORD_STATUS = @RECORD_STATUS
WHERE ID = @ID


------------------------------------------------------------------------------------------
/*
	sp_ADD_NEWS : THÊM 1 TIN TỨC MỚI
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_ADD_NEWS') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_ADD_NEWS

GO

CREATE PROCEDURE sp_ADD_NEWS
(	
	@CATEID INT,
	@TITLE NVARCHAR(300),
	@IMAGE NVARCHAR(300),
	@SUMMARY NTEXT,
	@CONTENT NTEXT,
	@AUTHORS NVARCHAR(50),
	@CREATE_DATE DATETIME,
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

INSERT INTO NEWS 
VALUES(@CATEID, @TITLE, @IMAGE, @SUMMARY, @CONTENT, @AUTHORS, @CREATE_DATE, @SORTED, @RECORD_STATUS)


------------------------------------------------------------------------------------------
/*
	sp_UPDATE_NEWS : CẬP NHẬT 1 TIN TỨC
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_UPDATE_NEWS') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_UPDATE_NEWS

GO

CREATE PROCEDURE sp_UPDATE_NEWS
(	
	@ID INT,
	@CATEID INT,
	@TITLE NVARCHAR(300),
	@IMAGE NVARCHAR(300),
	@SUMMARY NTEXT,
	@CONTENT NTEXT,
	@AUTHORS NVARCHAR(50),
	@CREATE_DATE DATETIME,
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

UPDATE NEWS
SET  CATEID = @CATEID
	,TITLE = @TITLE
	,IMAGE = @IMAGE
	,SUMMARY = @SUMMARY
	,CONTENT = @CONTENT
	,AUTHORS = @AUTHORS
	,CREATE_DATE = @CREATE_DATE
	,SORTED = @SORTED
	,RECORD_STATUS = @RECORD_STATUS
WHERE ID = @ID


------------------------------------------------------------------------------------------
/*
	sp_UPDATE_IMAGE_NEWS : CẬP NHẬT LINK IMAGE 1 TIN TỨC
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_UPDATE_IMAGE_NEWS') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_UPDATE_IMAGE_NEWS

GO

CREATE PROCEDURE sp_UPDATE_IMAGE_NEWS
(	
	@ID INT,	
	@IMAGE NVARCHAR(300)
)

AS

UPDATE NEWS
SET 
	IMAGE = @IMAGE	
WHERE ID = @ID


------------------------------------------------------------------------------------------
/*
	sp_ADD_MENUPARENT : THÊM 1 MENU PARENT
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_ADD_MENUPARENT') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_ADD_MENUPARENT

GO

CREATE PROCEDURE sp_ADD_MENUPARENT
(		
	@NAME NVARCHAR(200),
	@URL NVARCHAR(500),
	@TARGET NVARCHAR(50),
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

INSERT INTO MENUPARENT 
VALUES(@NAME, @URL, @TARGET, @SORTED, @RECORD_STATUS)


------------------------------------------------------------------------------------------
/*
	sp_UPDATE_MENUPARENT : CẬP NHẬT 1 MENUPARENT
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_UPDATE_MENUPARENT') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_UPDATE_MENUPARENT

GO

CREATE PROCEDURE sp_UPDATE_MENUPARENT
(	
	@ID INT,
	@NAME NVARCHAR(200),
	@URL NVARCHAR(500),
	@TARGET NVARCHAR(50),
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

UPDATE MENUPARENT
SET  NAME = @NAME
	,URL = @URL
	,[TARGET] = @TARGET
	,SORTED = @SORTED
	,RECORD_STATUS = @RECORD_STATUS
WHERE ID = @ID


------------------------------------------------------------------------------------------
/*
	sp_ADD_MENUCHILD : THÊM 1 MENU CHILD
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_ADD_MENUCHILD') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_ADD_MENUCHILD

GO

CREATE PROCEDURE sp_ADD_MENUCHILD
(		
	@NAME NVARCHAR(200),
	@PARENTID INT,
	@URL NVARCHAR(500),
	@TARGET NVARCHAR(50),
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

INSERT INTO MENUCHILD 
VALUES(@NAME, @PARENTID, @URL, @TARGET, @SORTED, @RECORD_STATUS)


------------------------------------------------------------------------------------------
/*
	sp_UPDATE_MENUCHILD : CẬP NHẬT 1 MENUCHILD
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_UPDATE_MENUCHILD') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_UPDATE_MENUCHILD

GO

CREATE PROCEDURE sp_UPDATE_MENUCHILD
(	
	@ID INT,
	@NAME NVARCHAR(200),
	@PARENTID INT,
	@URL NVARCHAR(500),
	@TARGET NVARCHAR(50),
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

UPDATE MENUCHILD
SET  NAME = @NAME
	,PARENTID = @PARENTID
	,URL = @URL
	,[TARGET] = @TARGET
	,SORTED = @SORTED
	,RECORD_STATUS = @RECORD_STATUS
WHERE ID = @ID


------------------------------------------------------------------------------------------
/*
	sp_ADD_SUPPORT : THÊM 1 SUPPORT
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_ADD_SUPPORT') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_ADD_SUPPORT

GO

CREATE PROCEDURE sp_ADD_SUPPORT
(		
	@NAME NVARCHAR(200),
	@IMAGE NVARCHAR(300),
	@URL NVARCHAR(500),
	@MOBILE NVARCHAR(50),
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

INSERT INTO SUPPORT 
VALUES(@NAME, @IMAGE, @URL, @MOBILE, @SORTED, @RECORD_STATUS)


------------------------------------------------------------------------------------------
/*
	sp_UPDATE_SUPPORT : CẬP NHẬT 1 SUPPORT
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_UPDATE_SUPPORT') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_UPDATE_SUPPORT

GO

CREATE PROCEDURE sp_UPDATE_SUPPORT
(	
	@ID INT,
	@NAME NVARCHAR(200),
	@IMAGE NVARCHAR(300),
	@URL NVARCHAR(500),
	@MOBILE NVARCHAR(50),
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

UPDATE SUPPORT
SET  NAME = @NAME
	,[IMAGE] = @IMAGE
	,URL = @URL
	,MOBILE = @MOBILE
	,SORTED = @SORTED
	,RECORD_STATUS = @RECORD_STATUS
WHERE ID = @ID

------------------------------------------------------------------------------------------
/*
	sp_ADD_ALBUM : THÊM 1 ALBUM
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_ADD_ALBUM') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_ADD_ALBUM

GO

CREATE PROCEDURE sp_ADD_ALBUM
(		
	@NAME NVARCHAR(200),
	@IMAGE NVARCHAR(300),		
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

INSERT INTO ALBUM 
VALUES(@NAME, @IMAGE, @SORTED, @RECORD_STATUS)


------------------------------------------------------------------------------------------
/*
	sp_UPDATE_ALBUM : CẬP NHẬT 1 ALBUM
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_UPDATE_ALBUM') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_UPDATE_ALBUM

GO

CREATE PROCEDURE sp_UPDATE_ALBUM
(	
	@ID INT,
	@NAME NVARCHAR(200),
	@IMAGE NVARCHAR(300),		
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

UPDATE ALBUM
SET  NAME = @NAME
	,[IMAGE] = @IMAGE
	,SORTED = @SORTED
	,RECORD_STATUS = @RECORD_STATUS
WHERE ID = @ID

------------------------------------------------------------------------------------------
/*
	sp_ADD_IMAGES : THÊM 1 IMAGES
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_ADD_IMAGES') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_ADD_IMAGES

GO

CREATE PROCEDURE sp_ADD_IMAGES
(		
	@NAME NVARCHAR(200),
	@ALBUMID INT,
	@IMAGE NVARCHAR(300),
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

INSERT INTO [IMAGE] 
VALUES(@NAME, @ALBUMID, @IMAGE, @SORTED, @RECORD_STATUS)


------------------------------------------------------------------------------------------
/*
	sp_UPDATE_IMAGES : CẬP NHẬT 1 ẢNH
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_UPDATE_IMAGES') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_UPDATE_IMAGES

GO

CREATE PROCEDURE sp_UPDATE_IMAGES
(	
	@ID INT,
	@NAME NVARCHAR(200),
	@ALBUMID INT,
	@IMAGE NVARCHAR(300),
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

UPDATE [IMAGE]
SET  NAME = @NAME
	,ALBUMID = @ALBUMID
	,[IMAGE] = @IMAGE
	,SORTED = @SORTED
	,RECORD_STATUS = @RECORD_STATUS
WHERE ID = @ID


------------------------------------------------------------------------------------------
/*
	sp_ADD_ADVERTISE : THÊM 1 QUẢNG CÁO
	
	1 : Trung tâm
	
	2 : Tin tức
	
	3 : Đào tạo
	
	4 : Hình ảnh
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_ADD_ADVERTISE') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_ADD_ADVERTISE

GO

CREATE PROCEDURE sp_ADD_ADVERTISE
(		
	@NAME NVARCHAR(200),	
	@IMAGE NVARCHAR(300),
	@URL NVARCHAR(500),
	@POSITION INT,
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

INSERT INTO ADVERTISE 
VALUES(@NAME, @IMAGE, @URL, @POSITION, @SORTED, @RECORD_STATUS)


------------------------------------------------------------------------------------------
/*
	sp_UPDATE_ADVERTISE : CẬP NHẬT 1 QUẢNG CÁO	
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_UPDATE_ADVERTISE') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_UPDATE_ADVERTISE

GO

CREATE PROCEDURE sp_UPDATE_ADVERTISE
(	
	@ID INT,
	@NAME NVARCHAR(200),	
	@IMAGE NVARCHAR(300),
	@URL NVARCHAR(500),
	@POSITION INT,
	@SORTED INT,
	@RECORD_STATUS BIT
)

AS

UPDATE ADVERTISE
SET  NAME = @NAME	
	,[IMAGE] = @IMAGE
	,URL = @URL
	,POSITION = @POSITION
	,SORTED = @SORTED
	,RECORD_STATUS = @RECORD_STATUS
WHERE ID = @ID


------------------------------------------------------------------------------------------
/*
	sp_CHANGE_PASSWORD : Đổi Password người dùng
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_CHANGE_PASSWORD') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_CHANGE_PASSWORD

GO

CREATE PROCEDURE sp_CHANGE_PASSWORD
(		
	@USERNAME NVARCHAR(50),	
	@PASSWORD NVARCHAR(50)	
)

AS

UPDATE ADMINISTRATOR
SET	 PASSWORD = @PASSWORD		
WHERE USERNAME = @USERNAME